package com.yj.provider.dynamicDataSource;

import com.yj.provider.pojo.Role;
import com.yj.provider.pojo.User;
import com.yj.provider.service.RoleService;
import com.yj.provider.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@Slf4j
public class CommonRun implements CommandLineRunner {

    @Autowired
    UserService userService;

    @Autowired
    RoleService roleService;

    @Override
    public void run(String... args) throws Exception {
        List<User> list = userService.findAll();
        log.info("数据源dev执行了list方法:==>{}",list);
        System.out.println(list);

        List<Role> roleList = roleService.findAll();
        log.info("数据源prod执行了list方法:==>{}",roleList);
        System.out.println(roleList);

    }
}
